version 15.1
clear all
capture log close
set matsize 1000
set more off
use "ms2020453.dta"
 
ssc install egenmore
ssc install tsegen
net from "http://www.stata-journal.com/software/sj3-2/"
net install st0039     		//install xtserial
ssc install xtdpdgmm
ssc install maptile
maptile_install using "http://files.michaelstepner.com/geo_state.zip"
ssc install spmap
ssc install outreg2
ssc install outreg

********************************************************************************
********************************************************************************
* CDD: Cumulative damages through t0 to t-6

**total
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double cdd`i' = rowtotal(L(0/`i').adj_total_damage_capitak, `n')
}
label variable cdd5 "Cumulative total damage through t-5"

**floods
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double flood`i' = rowtotal(L(0/`i').adj_flood_total_cptk, `n')
}
label variable flood5 "Cumulative flood damage through t-5"

**hurricane
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double hurricane`i' = rowtotal(L(0/`i').adj_hurricane_total_cptk, `n')
}
label variable hurricane5 "Cumulative hurricane damage through t-5"

**tornado
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double tornado`i' = rowtotal(L(0/`i').adj_tornado_total_cptk, `n')
}
label variable tornado5 "Cumulative tornado damage through t-5"

**drought
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double drought`i' = rowtotal(L(0/`i').adj_drought_total_cptk, `n')
}
label variable drought5 "Cumulative drought damage through t-5"

**hail
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double hail`i' = rowtotal(L(0/`i').adj_hail_total_cptk, `n')
}
label variable hail5 "Cumulative hail damage through t-5"

**others
forvalues i = 0/6 {
    local n = `i' + 1
    tsegen double others`i' = rowtotal(L(0/`i').adj_otherevents_total_cptk, `n')
}
label variable others5 "Cumulative all others damage through t-5"


* FC and HRC

egen tres_hc = xtile(hc), n(3) by(year)
tab tres_hc, generate(hc)
sum hc if hc1==1
sum hc if hc3==1
rename hc1 lowhc
rename hc3 highhc

egen tres_fc = xtile(fc), n(3) by(year)
tab tres_fc, generate(fc)
sum fc if fc1==1
sum fc if fc3==1
rename fc1 lowfc
rename fc3 highfc


* Supsample

gen disaster_rdf=0
replace disaster_rdf=1 if state=="alaska" | state=="arizona" | state=="california" | state=="florida" | state=="hawaii" ///
| state=="idaho" | state=="iowa" | state=="kentucky" | state=="maine" | state=="massachusetts" | state=="michigan" ///
| state=="minnesota" |  state=="mississippi" | state=="missouri" | state=="montana" ///
| state=="nebraska" | state=="new jersey" | state=="new mexico" | state=="new york" | state=="north carolina" ///
| state=="north dakota" | state=="oklahoma" | state=="oregon" | state=="pennsylvania" | state=="rhode island" ///
| state=="south carolina" | state=="south dakota" | state=="tennessee" | state=="texas" | state=="utah" ///
| state=="vermont" | state=="washington" | state=="west virginia" | state=="wisconsin" | state=="wyoming"
label variable disaster_rdf "States with RDF for Funding Disaster Costs"

save "ms2020453_analysis.dta", replace
********************************************************************************
**********************************ANALYSIS**************************************
********************************************************************************

xtset state_en year

global IV cdd5 fc hc 
global interact i.highfc#c.cdd5 i.lowfc#c.cdd5 i.highhc#c.cdd5 i.lowhc#c.cdd5
global CV confrontation_new control_r control_d ecycle confrontation_damage adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita ///
rdf_deposit_new1 rdf_deposit_new2 rdf_deposit_new3 rdf_withdrawal_new1 rdf_withdrawal_new2 rdf_withdrawal_new3 ///
governor_bgt leg_bgt gsign_bb minority youth senior lngdp_capita_dollar unemploy lnpopulation major i.year i.state_en

*AUTOCORRELATIONS
xtserial pewrdf_exp $IV confrontation_new control_r control_d ecycle confrontation_damage adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita ///
rdf_deposit_new1 rdf_deposit_new2 rdf_deposit_new3 rdf_withdrawal_new1 rdf_withdrawal_new2 rdf_withdrawal_new3 ///
governor_bgt leg_bgt gsign_bb minority youth senior lngdp_capita_dollar unemploy lnpopulation major

*HETEROSKEDASTICITY
reg pewrdf_exp l.pewrdf_exp $IV $interact $CV
hettest

***************************MODELS M1-M4: DV=RDF (Table 3)***********************

*OLS: Model1
reg pewrdf_exp l.pewrdf_exp $IV $interact $CV if disaster_rdf==1 & state !="alaska", robust
estat ic
gen subsample=e(sample)
outreg2 using table3_ols.doc, adds("Adj R-squared", e(r2_a)) dec(3)word onecol append

*OLS: Model3
reg pewrdf_exp l.pewrdf_exp $IV $interact $CV if state !="alaska", robust
estat ic
gen fullsample=e(sample)
outreg2 using table3_ols.doc, adds("Adj R-squared", e(r2_a), "P>F", e(p)) dec(3)word onecol append

*GMM: Model2
forvalues i = 1/7 {
    local n = `i' + 1
    xtdpdgmm L(0/1).pewrdf_exp $IV $interact $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp ///
	fc confrontation_new adj_intergovaids_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 `n') ///
	difference model(difference)) onestep overid vce(robust)
estat overid
}

gen highfc_cdd5=highfc*cdd5
gen lowfc_cdd5=lowfc*cdd5
gen highhc_cdd5=highhc*cdd5
gen lowhc_cdd5=lowhc*cdd5

global interact_gmm highfc_cdd5 lowfc_cdd5 highhc_cdd5 lowhc_cdd5
xtdpdgmm L(0/1).pewrdf_exp $IV $interact_gmm $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 7) difference model(difference)) onestep overid vce(robust)
estat serial, ar(1/7)
estat overid
outreg2 using table3_gmm.doc, adds("Hansen test",  e(chi2_J)) dec(3)word onecol append


*GMM: Model4
forvalues i = 1/7 {
    local n = `i' + 1
    xtdpdgmm L(0/1).pewrdf_exp $IV $interact $CV if state !="alaska", ///
	gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 `n') ///
	difference model(difference)) onestep overid vce(robust)
estat overid
}

xtdpdgmm L(0/1).pewrdf_exp $IV $interact_gmm $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 7) difference model(difference)) onestep overid vce(robust)
estat serial, ar(1/7)
estat overid
outreg2 using table3_gmm.doc, adds("Hansen test",  e(chi2_J)) dec(3)word onecol append

*************************MODELS M5-M6: DV=UGFB (Table 4)************************

*Model5
global CVgfb confrontation_new control_r control_d ecycle confrontation_damage adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita ///
governor_bgt leg_bgt gsign_bb minority youth senior ///
lnpi unemploy lnpopulation major i.year i.state_en 
global CVgfbfe confrontation_new control_r control_d ecycle confrontation_damage adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita ///
governor_bgt leg_bgt gsign_bb minority youth senior ///
lnpi unemploy lnpopulation major i.year

xtreg uas_gfb_m_exp l.uas_gfb_m_exp $IV $interact $CVgfbfe, fe robust
estat ic
outreg2 using table4.doc, adds("Adj R-squared", e(r2_a), "P>F", e(p)) dec(3)word onecol append

*Model6
forvalues i = 1/7 {
    local n = `i' + 1
    xtdpdgmm L(0/1).uas_gfb_m_exp $IV $interact_gmm $CVgfb, ///
	gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio ///
	adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 `n') ///
	difference model(difference)) onestep overid vce(robust)
estat overid
}
xtdpdgmm L(0/1).uas_gfb_m_exp $IV $interact_gmm $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 5) difference model(difference)) onestep overid vce(robust)
estat serial, ar(1/7)
estat overid
outreg2 using table4.doc, adds("Hansen test",  e(chi2_J)) dec(3)word onecol append


save "ms2020453_analysis.dta", replace

************************DESCRIPTIVE STATS & VISUALIZATION**********************

* Summary table (Table 1)
global CV_summary confrontation_new control_r control_d ecycle adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita ///
deposit_new1 deposit_new2 deposit_new3 deposit_new4 withdrawal_new1 withdrawal_new2 withdrawal_new3 withdrawal_new4 ///
governor_bgt leg_bgt gsign_bb minority youth senior lnpi lngdp_capita_dollar unemploy lnpopulation major

sum pewrdf_exp uas_gfb_m_exp $IV $CV_summary if subsample==1
putexcel set table1.xlsx, replace
putexcel A1= "Subsample"
tabstat pewrdf_exp uas_gfb_m_exp $IV $CV_summary if subsample==1, stat(n mean sd min max) save
return list
putexcel A2= matrix(r(StatTotal)'), names
sum pewrdf_exp uas_gfb_m_exp $IV $CV_summary if fullsample==1
putexcel H1= "Fullsample"
tabstat pewrdf_exp uas_gfb_m_exp $IV $CV_summary if fullsample==1, stat(n mean sd min max) save
return list
putexcel H2= matrix(r(StatTotal)'), names

local Var pewrdf_exp uas_gfb_m_exp $IV $CV_summary
foreach var of varlist `Var' {
sum `var' if subsample==1
gen mean`var' = r(mean) 
ttest mean`var' = `var' if fullsample==1
}

* Graph (figure 1)
use "ms2020453_analysis.dta", clear
bysort year: egen average_uas_gfb_exp = mean(uas_gfb_m_exp)
tssmooth ma uub_adj_5=average_uas_gfb_exp, window(4 1 0)
bysort year: egen ave_pewrdf_exp = mean(pewrdf_exp)
tssmooth ma pewrdf_exp_5=ave_pewrdf_exp, window(4 1 0)

twoway (tsline average_uas_gfb_exp ave_pewrdf_exp) if tin(2002, 2017), saving(figure1)

* Distrigution (Figure 2-4, appendix 3-3)
by state_en, sort: egen mpewrdf_exp = mean(pewrdf_exp)
keep if year==2017
rename state state2
rename ab_state state
replace mpewrdf_exp=0 if state2=="alabama"
maptile mpewrdf_exp, geography(state) geoid(state) rangecolor(white navy) savegraph(figure2)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen muas_gfb_m_exp = mean(uas_gfb_m_exp)
keep if year==2017
rename state state2
rename ab_state state
maptile muas_gfb_m_exp, geography(state) geoid(state) rangecolor(white gray) savegraph(figure3)

**by disaster type
use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_total_damage_capitak = mean(adj_total_damage_capitak)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_total_damage_capitak, geography(state) geoid(state) savegraph(figure4)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_flood_total_cptk = mean(adj_flood_total_cptk)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_flood_total_cptk, geography(state) geoid(state) rangecolor(white red) savegraph(flood)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_hurricane_total_cptk = mean(adj_hurricane_total_cptk)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_hurricane_total_cptk, geography(state) geoid(state) nquantiles(25) rangecolor(white red) savegraph(hurricane)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_tornado_total_cptk = mean(adj_tornado_total_cptk)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_tornado_total_cptk, geography(state) geoid(state) rangecolor(white red) savegraph(tornado)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_drought_total_cptk = mean(adj_drought_total_cptk)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_drought_total_cptk, geography(state) geoid(state) rangecolor(white red) savegraph(drought)

use "ms2020453_analysis.dta", clear
by state_en, sort: egen madj_hail_total_cptk = mean(adj_hail_total_cptk)
keep if year==2017
rename state state2
rename ab_state state
maptile madj_hail_total_cptk, geography(state) geoid(state) rangecolor(white red) savegraph(hail)

* Visualization of moderating effect (figure5)

use "ms2020453_analysis.dta", clear
xtset state_en year
reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_fc==1, robust
est sto result_1
reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_fc==2, robust
est sto result_2
reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_fc==3, robust
est sto result_3
coefplot result_1, bylabel(Low-fc group t=1)||result_2, bylabel(Mid-fc group t=2)||result_3, bylabel(High-fc group t=3)||, keep (cdd5) xline(0) levels(95) saving(figure5_1)
drop _est_result_1 _est_result_2 _est_result_3


reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_hc==1, robust
est sto result_1
reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_hc==2, robust
est sto result_2
reg pewrdf_exp l.pewrdf_exp $IV $CV if state !="alaska" & tres_hc==3, robust
est sto result_3
coefplot result_1, bylabel(Low-hrc group t=1)||result_2, bylabel(Mid-hrc group t=2)||result_3, bylabel(High-hrc group t=3)||, keep (cdd5) xline(0) levels(95) saving(figure5_2)


******************************ROBSUTNESS CHECKS*********************************
use "ms2020453_analysis.dta", clear

* Apendix 1
global IV0 cdd0 fc hc
global IV1 cdd1 fc hc 
global IV2 cdd2 fc hc
global IV3 cdd3 fc hc
global IV4 cdd4 fc hc
global IV6 cdd6 fc hc
global interact0 i.highfc#c.cdd0 i.lowfc#c.cdd0 i.highhc#c.cdd0 i.lowhc#c.cdd0
global interact1 i.highfc#c.cdd1 i.lowfc#c.cdd1 i.highhc#c.cdd1 i.lowhc#c.cdd1
global interact2 i.highfc#c.cdd2 i.lowfc#c.cdd2 i.highhc#c.cdd2 i.lowhc#c.cdd2
global interact3 i.highfc#c.cdd3 i.lowfc#c.cdd3 i.highhc#c.cdd3 i.lowhc#c.cdd3
global interact4 i.highfc#c.cdd4 i.lowfc#c.cdd4 i.highhc#c.cdd4 i.lowhc#c.cdd4
global interact6 i.highfc#c.cdd6 i.lowfc#c.cdd6 i.highhc#c.cdd6 i.lowhc#c.cdd6

**t0

xtdpdgmm L(0/1).pewrdf_exp $IV0 $interact0 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(1 5) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV0 $interact0 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(1 5) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV0 $interact0 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(1 5) difference model(difference)) onestep overid vce(robust)

**t-1

xtdpdgmm L(0/1).pewrdf_exp $IV1 $interact1 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV1 $interact1 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV1 $interact1 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)

**t-2

xtdpdgmm L(0/1).pewrdf_exp $IV2 $interact2 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV2 $interact2 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV2 $interact2 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)


**t-3

xtdpdgmm L(0/1).pewrdf_exp $IV3 $interact3 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV3 $interact3 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV3 $interact3 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)

**t-4

xtdpdgmm L(0/1).pewrdf_exp $IV4 $interact4 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV4 $interact4 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV4 $interact4 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)

**t-6

xtdpdgmm L(0/1).pewrdf_exp $IV6 $interact6 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV6 $interact6 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV6 $interact6 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)

*Appendix 2
use "ms2020453_analysis.dta", clear
xtset state_en year

**mean +-0.25
sum fc
gen lowgroup = 0
replace lowgroup=1 if fc < (r(mean)-0.25*r(sd))
sum fc
gen highgroup = 0
replace highgroup=1 if fc > (r(mean)+0.25*r(sd))
sum hc
gen lowgrouph = 0
replace lowgrouph=1 if hc < (r(mean)-0.25*r(sd))
sum hc
gen highgrouph = 0
replace highgrouph=1 if hc > (r(mean)+0.25*r(sd))
global interact25 i.highgroup#c.cdd5 i.lowgroup#c.cdd5 i.highgrouph#c.cdd5 i.lowgrouph#c.cdd5

xtdpdgmm L(0/1).pewrdf_exp $IV $interact25 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV $interact25 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV $interact25 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 6) difference model(difference)) onestep overid vce(robust)

**mean +-0.5sd
drop lowgroup highgroup lowgrouph highgrouph
sum fc
gen lowgroup = 0
replace lowgroup=1 if fc < (r(mean)-0.5*r(sd))
sum fc
gen highgroup = 0
replace highgroup=1 if fc > (r(mean)+0.5*r(sd))
sum hc
gen lowgrouph = 0
replace lowgrouph=1 if hc < (r(mean)-0.5*r(sd))
sum hc
gen highgrouph = 0
replace highgrouph=1 if hc > (r(mean)+0.5*r(sd))
global interact50 i.highgroup#c.cdd5 i.lowgroup#c.cdd5 i.highgrouph#c.cdd5 i.lowgrouph#c.cdd5

xtdpdgmm L(0/1).pewrdf_exp $IV $interact50 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV $interact50 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV $interact50 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 6) difference model(difference)) onestep overid vce(robust)

**mean +-0.70sd
drop lowgroup highgroup lowgrouph highgrouph
sum fc
gen lowgroup = 0
replace lowgroup=1 if fc < (r(mean)-0.70*r(sd))
sum fc
gen highgroup = 0
replace highgroup=1 if fc > (r(mean)+0.70*r(sd))
sum hc
gen lowgrouph = 0
replace lowgrouph=1 if hc < (r(mean)-0.70*r(sd))
sum hc
gen highgrouph = 0
replace highgrouph=1 if hc > (r(mean)+0.70*r(sd))
global interact70 i.highgroup#c.cdd5 i.lowgroup#c.cdd5 i.highgrouph#c.cdd5 i.lowgrouph#c.cdd5

xtdpdgmm L(0/1).pewrdf_exp $IV $interact70 $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IV $interact70 $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IV $interact70 $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 6) difference model(difference)) onestep overid vce(robust)

*Appendix 3
xtset state_en year

global IVtype flood5 hurricane5 tornado5 drought5 hail5 others5 fc hc

local Var flood5 hurricane5 tornado5 drought5 hail5 others5
foreach var in `Var' {
gen fc`var'=`var'*fc
gen hc`var'=`var'*hc
}
global Interaction_type fcflood5 fchurricane5 fctornado5 fcdrought5 fchail5 fcothers5 hcflood5 hchurricane5 hctornado5 hcdrought5 hchail5 hcothers5

xtdpdgmm L(0/1).pewrdf_exp $IVtype $Interaction_type $CV if disaster_rdf==1 & state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).pewrdf_exp $IVtype $Interaction_type $CV if state !="alaska", gmmiv(l.pewrdf_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lngdp_capita_dollar unemploy, lagrange(0 4) difference model(difference)) onestep overid vce(robust)
xtdpdgmm L(0/1).uas_gfb_m_exp $IVtype $Interaction_type $CVgfb, gmmiv(l.uas_gfb_m_exp fc confrontation_new adj_intergovaids_capita surplus_ratio adj_currentexp_capita debt_capita lnpopulation lnpi unemploy, lagrange(0 6) difference model(difference)) onestep overid vce(robust)

